// address_book.cpp
// Implementation of the AddressBookEntry class
#include "address-book.h"

// AddressBookEntry Constructor
AddressBookEntry::AddressBookEntry(	const Person& person,
								   const string& image_filename)
								   :_person(person),
								   _image_ptr()
{
	// dynamically allocate memory for the image
	if (image_filename != "") {
		// ignore (for now) what will happen if there is a memory allocation failure
		_image_ptr.reset(new Image(image_filename));
	}
}

string AddressBookEntry::getImageName() const
{
	if (_image_ptr != 0)
		return _image_ptr->name();
	else return "No image!";
}

void AddressBookEntry::setImageName(string newname)
{
	if (_image_ptr != 0) _image_ptr->name(newname);
}

bool AddressBookEntry::operator==(const AddressBookEntry& rhs) const
{
    if( _person == rhs._person && _image_ptr == rhs._image_ptr )

        return true;
    else
        return false;
}
